<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>position</title>
    <style>
        .cards {
            border: red solid 1px;
            position: relative;
            height: 2000px;
        }

        .card {
            width: 7rem;
            height: 7rem;
        }

        .card1 {
            margin-top: 20px;
            background-color: aqua;
            position: sticky;
            top: 0;
        }
    </style>
</head>

<body>
    <div class="cards">
        <div class="card card1"></div>
    </div>
</body>

</html>